package com.sq.shortlink.admin.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sq.shortlink.admin.common.convension.result.Result;
import com.sq.shortlink.admin.remoto.RecycleBinRemoteService;
import com.sq.shortlink.admin.remoto.dto.req.RecycleBinRecoverReqDTO;
import com.sq.shortlink.admin.remoto.dto.req.RecycleBinRemoveDTO;
import com.sq.shortlink.admin.remoto.dto.req.RecycleBinSaveReqDTO;
import com.sq.shortlink.admin.remoto.dto.req.ShortLinkRecycleBinPageReqDTO;
import com.sq.shortlink.admin.remoto.dto.resp.ShortLinkPageRespDTO;
import com.sq.shortlink.admin.service.RecycleBinService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 短链接回收站控制层
 * @author quan
 */
@RestController
@RequiredArgsConstructor
public class RecycleBinController {

    private final RecycleBinRemoteService recycleBinRemoteService = new RecycleBinRemoteService() {
    };
    private final RecycleBinService recycleBinService;

    @PostMapping("/api/short-link/v1/admin/recycle-bin/save")
    public Result<Void> saveRecycleBin(@RequestBody RecycleBinSaveReqDTO requestParam){
        return recycleBinRemoteService.saveRecycleBin(requestParam);
    }

    @PostMapping("/api/short-link/v1/admin/recycle-bin/page")
    public Result<IPage<ShortLinkPageRespDTO>> pageRecycleBinShortLink(@RequestBody ShortLinkRecycleBinPageReqDTO requestParam) {
        return recycleBinService.pageRecycleBinShortLink(requestParam);
    }

    @PostMapping("/api/short-link/v1/admin/recycle-bin/recover")
    public Result<Void> recycleBinRecover(@RequestBody RecycleBinRecoverReqDTO requestParam){
        return recycleBinRemoteService.recycleBinRecover(requestParam);
    }

    @PostMapping("/api/short-link/v1/admin/recycle-bin/remove")
    public Result<Void> recycleBinRecover(@RequestBody RecycleBinRemoveDTO requestParam){
        return recycleBinRemoteService.recycleBinRemove(requestParam);
    }
}
